﻿namespace Vcare.DAL
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using Vcare.Models;
  using System.Data.Entity.ModelConfiguration.Conventions;
  using System.Data.Entity;
  using System.Data.Entity.ModelConfiguration;


  public class VcareContext:DbContext
  {
    public DbSet<Members> Members { get; set; }
    public DbSet<Salutations> Salutations { get; set; }
    public DbSet<CallCentres> CallCentres { get; set; }
    public DbSet<Authority> Authority { get; set; }
    public DbSet<UserInfo> UserInfo { get; set; }
    public DbSet<Users> Users { get; set; }
    public DbSet<Companies> Companies { get; set; }
    public DbSet<PurchasedMembers> PurchasedMembers { get; set; }
    public DbSet<AllocatedMembers> AllocatedMembers { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
      modelBuilder.Entity<Members>().HasKey(x => x.MembersID);
      modelBuilder.Entity<Salutations>().HasKey(x => x.SalutationID);
      modelBuilder.Entity<CallCentres>().HasKey(x => x.CallCentreID);
      modelBuilder.Entity<Authority>().ToTable("Authority");
      modelBuilder.Entity<Authority>().HasKey(x => x.AuthorityID);
      modelBuilder.Entity<UserInfo>().ToTable("UserInfo");
      modelBuilder.Entity<UserInfo>().HasKey(x => x.UserInfoID);
      modelBuilder.Entity<Users>().HasKey(x => x.UserId);
      modelBuilder.Entity<Companies>().HasKey(x => x.CompanyID);
      modelBuilder.Entity<PurchasedMembers>().HasKey(x => x.PurchasedMembersID);
      modelBuilder.Entity<AllocatedMembers>().HasKey(x => x.AllocatedMembersID);

      base.OnModelCreating(modelBuilder);
    }
  }
}